home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 014 / convcom.bas (.txt) < prev    next >
Encoding:
GW-BASIC  |  1984-04-24  |  3.4 KB  |  70 lines

  1. 10  ' COPYRIGHT 1982, RICHARD M. SCHINNELL
  2. 20  ' This Program is called CONV.BAS
  3. 30  ON ERROR GOTO 640
  4. 40  CLS:LOCATE 12,1
  5. 45  PRINT"COPYRIGHT 1982, Richard Schinnell Rockville,Maryland 301 949-8848 "
  6. 50  PRINT"This program will convert .COM files to a basic program which"
  7. 60  PRINT"you then can transmit to someone over the Telephone. They
  8. 70  PRINT"can then run the basic program and it will re-create the .COM pgm.
  9. 80  PRINT"just like you had it.       E N J O Y   RICH......":PRINT
  10. 90  INPUT "Name of the COM or EXE File to convert (<5001 Bytes )?: ";FIL1$
  11. 100  PRINT "To call the program with the same name with .BAS ext hit C/R"
  12. 110  INPUT "WHAT do you wish to call the basic program ?: ";FIL2$
  13. 120  IF LEN(FIL2$)<1 THEN FIL2$=MID$(FIL1$,1,(INSTR(FIL1$,".")-1))+".BAS"
  14. 130  RICH$="1000 DATA ":NUMLIN=1010:X=0:GRAND#=0:CNT=1
  15. 140  IF FIL1$=FIL2$ THEN CLS:LOCATE 12,15:PRINT "DUPLICATE FILE NAMES ":GOTO 10
  16. 150  OPEN FIL1$ FOR INPUT AS #1:CLOSE #1
  17. 160  OPEN  FIL1$  AS #1 LEN=1 ' opening the .COM file
  18. 170  V= VARPTR(#1) ' looking at the FCB
  19. 180  L0=PEEK(V) ' getting the type of file
  20. 190  IF L0<>4 THEN 640 ' if file not random then abort
  21. 200  L1=PEEK(V+17) + 256 * PEEK(V+18) ' this gets the filesize in bytes
  22. 210  LIMIT = L1:IF LIMIT>5000 THEN GOTO 640  ' if it's too big then abort
  23. 220  OPEN  FIL2$  FOR OUTPUT AS #2 ' opening up the .bas file this pgm creates
  24. 230  GOSUB 430
  25. 240  PRINT #2," 99 DATA ";STR$(LIMIT)
  26. 250  FIELD #1,1 AS GETS$
  27. 260  X =X +1:IF X =< LIMIT THEN GET #1,X ELSE 360
  28. 270  RICH1$=STR$(ASC(GETS$))
  29. 280  IF CNT <13 THEN RICH$=RICH$+MID$(RICH1$,2,LEN(RICH1$)-1)+",":CNT=CNT+1:GRAND#=GRAND#+ASC(GETS$):GOTO 260
  30. 290  GOTO 360
  31. 300  LOCATE 20,5:PRINT     "total ASCII count is ";GRAND#
  32. 310  PRINT #2,"5000 PRINT ";CHR$(34);"* * ERROR VERIFY DATA * * * ";CHR$(34)
  33. 320  PRINT #2,"5010 CLOSE:END"
  34. 330  LOCATE 18,1:PRINT SPC(78);:LOCATE 18,1:PRINT RICH$;
  35. 340  LOCATE 20,1:PRINT" You have sucessfully created file named ";FIL2$
  36. 350  CLOSE:END
  37. 360  RICH$=LEFT$(RICH$,(LEN(RICH$)-1))
  38. 370  CNT=1:PRINT #2,RICH$:NUMLIN=NUMLIN+1
  39. 380  LOCATE 18,1:PRINT SPC(78);:LOCATE 18,1:PRINT RICH$;
  40. 390  IF X = LIMIT+1 THEN PRINT #2, RIGHT$(STR$(NUMLIN),4);" DATA ";STR$(GRAND#):GOTO 310
  41. 400  LIN$=RIGHT$(STR$(NUMLIN),4)
  42. 410  RICH$=LIN$+" DATA "+MID$(RICH1$,2,LEN(RICH1$)-1)+",":GRAND#=GRAND#+ASC(GETS$)
  43. 420  GOTO 260
  44. 430  PRINT #2,"  1 CLS:PRINT ";CHR$(34);"THIS basic PROGRAM WAS AUTOMATICALLY CREATED BY CONVERT.BAS";CHR$(34)
  45. 440  PRINT #2,"  2 PRINT";CHR$(34);"Copyright 1982 ,Rich Schinnell Rockville,MD. Not for Sale.";CHR$(34)
  46. 450  PRINT #2,"  3 PRINT ";CHR$(34);"This program will automatically generate you a .COM program named ";FIL1$;CHR$(34);":PRINT "
  47. 460  PRINT #2,"  4 ON ERROR GOTO 5000"
  48. 465  PRINT #2,"  6 INPUT ";CHR$(34);"The file will be saved on the default drive.Place disk in the drive then Strike any key ";CHR$(34);"; SCHINNELL$"
  49. 470  PRINT #2,"  9 PRINT:PRINT ";CHR$(34);" Now reading the data statements, wait!";CHR$(34)
  50. 480  PRINT #2," 10 RESTORE:READ T:FOR I = 1 TO T:READ N:X#=X#+N:NEXT I"
  51. 490  PRINT #2," 20 READ TOT# :IF TOT#<>X# THEN 5000"
  52. 500  PRINT#2," 22 CLS:LOCATE 12,5:PRINT ";CHR$(34);"Now writing file NAMED ";FIL1$;" standby please ";CHR$(34)
  53. 510  PRINT #2," 30 RESTORE"
  54. 520  IF INSTR(FIL1$,":")=2 THEN FIL3$=MID$(FIL1$,3,13) ELSE FIL3$=FIL1$
  55. 530  PRINT #2," 40 OPEN ";CHR$(34);"R";CHR$(34);", #1,";CHR$(34);FIL3$;CHR$(34);",1 "
  56. 540  PRINT #2," 50 FIELD #1, 1 AS N$
  57. 550  PRINT #2," 60 READ N"
  58. 560  PRINT #2," 70 FOR I = 1 TO N
  59. 570  PRINT #2," 80 READ N:LSET N$=CHR$(N):
  60. 580  PRINT #2," 92 PUT #1 :NEXT I:CLOSE"
  61. 590  PRINT #2," 94 PRINT ";CHR$(34); FIL3$;" CREATED * *";CHR$(34);":GOTO 5010"
  62. 600  CLS:LOCATE 12,5:PRINT "I am now reading file named ";FIL1$
  63. 610  LOCATE 14,5:PRINT     "I am now writing file named ";FIL2$
  64. 620  LOCATE 16,5:PRINT     "the file size of the input file is ";LIMIT
  65. 630  RETURN
  66. 640  PRINT " you had an error ";ERR;" in line # ";ERL
  67. 650  PRINT "Probably you named a file which does not exist "
  68. 660  PRINT "try again Charlie........
  69. 670  END
  70.